package com.sparrow.gate.iohander;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class MinaServerIoHandler extends IoHandlerAdapter
{
    private final static Logger logger = LoggerFactory.getLogger(MinaServerIoHandler.class);

    @PostConstruct
    public void test()
    {
        logger.info("MinaServerIoHandler ----- PostConstruct!!!!!!!!!");
    }
    @Override
    public void sessionClosed(IoSession session) throws Exception
    {
        logger.info("Tcp Closed!");
        super.sessionClosed(session);
    }

    @Override
    public void sessionCreated(IoSession session) throws Exception
    {
        logger.info("Tcp Connect!");
        super.sessionCreated(session);
    }

    @Override
    public void messageReceived(IoSession session, Object message) throws Exception
    {
        logger.info("MinaServerIoHandler receive :" + message.toString());
        super.messageReceived(session, message);
    }

    @Override
    public void sessionIdle(IoSession session, IdleStatus status) throws Exception
    {
        super.sessionIdle(session, status);
    }
}
